<template>
  <el-dialog
    title="物流进度"
    ref="kuaidi"
    :visible.sync="dialogKuaidiVisible"
    :before-close="dialogClose"
  >
    <el-timeline>
      <el-timeline-item 
      v-for="(item, index) in list" 
      :key="index"
      :timestamp="item.time"
      >
      {{item.context}}
      </el-timeline-item>
    </el-timeline>
  </el-dialog>
</template>
<script>
export default {
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      dialogKuaidiVisible: false,
      list: [],
    };
  },
  methods: {
    async initKuaiDiInfo() {
      try {
        let result = await this.$api.getKuaidiList(815294206237577);
        // console.log(result);
        if (result == "error") return;
        this.list = result;
      } catch (error) {
        console.log("物流信息列表加载错误:", error);
      }
    },
    dialogClose() {
      this.$emit("update:visible", false);
    },
  },
  watch: {
    visible() {
      this.dialogKuaidiVisible = this.visible;
    },
  },
  created() {
    this.initKuaiDiInfo();
  },
};
</script>